#include "mpRandomUtils.h"

#include <boost/random/discrete_distribution.hpp>
#include <boost/uuid/uuid.hpp>
#include <boost/uuid/uuid_io.hpp>
#include <boost/uuid/uuid_generators.hpp>


namespace MP{
namespace RandomUtils{

////private member
//namespace{
//} //private member

/**
 * @brief 获取min至max之间的随机整数
 * @param min 最小值
 * @param max 最大值
 * @return
 */
int getRandomInt(int min, int max){
    static boost::random::mt19937 gen(std::time(0));
    boost::random::uniform_int_distribution<> dist(min, max);
    return dist(gen);
}

/**
 * @brief 获取uuid
 * @return
 */
std::string getUUID(){
    boost::uuids::uuid a_uuid = boost::uuids::random_generator()(); // 这里是两个() ，因为这里是调用的 () 的运算符重载
    auto txt = boost::uuids::to_string(a_uuid);
    return txt;
}

/**
 * @brief 获取指定长度的随机字符串
 * @param length
 * @return
 */
std::string getRandomString(int length){
    std::string out;
    int i = 0;
    for (i = 0; i < length - 1; i++)
    {
        out += 'a' + getRandomInt(1,100) % 26;
    }
    return out;
}

}   //END RandomUtils
}   //END MP
